import org.springframework.web.context.support.WebApplicationContextUtils

class BootStrap {

    def init = { servletContext ->
		def appCtx = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext)
		
		// this is the auth plugin bit
		appCtx.authenticationService.events.onConfirmAccount= { user ->
			// user is the domain object, AuthenticationUser unless you have changed it
			return true // always require confirmation no matter who it is or what their email address is
		}
		appCtx.authenticationService.events.onSignup = { params ->
			// params contains "user" - the domain object, and "extraParams" - all the params passed to the controller signup action
			appCtx.emailService.sendUserConfirmationEmail(params)
		}
	
		// this is dependent on your confirmation mechanism
		appCtx.emailService.onConfirmation = { userToken ->
			appCtx.authenticationService.confirmUser(userToken)
		}
		
		appCtx.dealService.crearUnDealCompletoTest()
    }
    def destroy = {
    }
}
